package com.ruoyi.ky450.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.utils.DateUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.ky450.domain.EquipCannon;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.ky450.mapper.EquipMissileMapper;
import com.ruoyi.ky450.domain.EquipMissile;
import com.ruoyi.ky450.service.IEquipMissileService;
import org.springframework.util.CollectionUtils;

/**
 * 导弹Service业务层处理
 *
 * @author ruoyi
 * @date 2025-01-16
 */
@Slf4j
@Service(value = "EquipMissileServiceImpl")
public class EquipMissileServiceImpl extends EquipParentService implements IEquipMissileService
{
    @Autowired
    private EquipMissileMapper equipMissileMapper;

    /**
     * 查询导弹
     *
     * @param id 导弹主键
     * @return 导弹
     */
    @Override
    public EquipMissile selectEquipMissileById(Long id)
    {
        return equipMissileMapper.selectEquipMissileById(id);
    }

    @Override
    public EquipMissile getByEBInfoId(Long id) {
        EquipMissile equipMissile = new EquipMissile();
        equipMissile.setEquipBaseInfoId(id);
        List<EquipMissile> list = this.selectEquipMissileList(equipMissile);
        if(!CollectionUtils.isEmpty(list)){
            return list.get(0);
        }
        return null;
    }

    /**
     * 查询导弹列表
     *
     * @param equipMissile 导弹
     * @return 导弹
     */
    @Override
    public List<EquipMissile> selectEquipMissileList(EquipMissile equipMissile)
    {
        return equipMissileMapper.selectEquipMissileList(equipMissile);
    }

    /**
     * 新增导弹
     *
     * @param equipMissile 导弹
     * @return 结果
     */
    @Override
    public int insertEquipMissile(EquipMissile equipMissile)
    {
        equipMissile.setCreateTime(DateUtils.getNowDate());
        return equipMissileMapper.insertEquipMissile(equipMissile);
    }

    /**
     * 修改导弹
     *
     * @param equipMissile 导弹
     * @return 结果
     */
    @Override
    public int updateEquipMissile(EquipMissile equipMissile)
    {
        equipMissile.setUpdateTime(DateUtils.getNowDate());
        return equipMissileMapper.updateEquipMissile(equipMissile);
    }

    /**
     * 批量删除导弹
     *
     * @param ids 需要删除的导弹主键
     * @return 结果
     */
    @Override
    public int deleteEquipMissileByIds(Integer[] ids)
    {
        return equipMissileMapper.deleteEquipMissileByIds(ids);
    }

    /**
     * 删除导弹信息
     *
     * @param id 导弹主键
     * @return 结果
     */
    @Override
    public int deleteEquipMissileById(Long id)
    {
        return equipMissileMapper.deleteEquipMissileById(id);
    }
}
